#ifndef QPOINTFSEDITORDIALOG_H
#define QPOINTFSEDITORDIALOG_H

#include "property_editor_global.h"

#include <QDialog>
#include <QVariant>
#include <QTreeWidgetItem>

enum enPointType
{
    PT_LINE,
    PT_POLYGON
};

namespace Ui {
class QPointFsEditorDialog;
}

class PROPERTY_EDITORSHARED_EXPORT QPointFsEditorDialog : public QDialog
{
    Q_OBJECT
    
public:
    explicit QPointFsEditorDialog(const QVariant& value,enPointType type=PT_POLYGON,QWidget *parent = 0);
    ~QPointFsEditorDialog();
    
    int get_ret();
    QVariant    get_value();
protected:
    bool    eventFilter(QObject *, QEvent *);
    void    point_draw();
    void    handle_draw(QWidget* wid);

    void    handle_mouse_press(QWidget* wid,QMouseEvent* e);
    void    handle_mouse_move(QWidget* wid,QMouseEvent* e);
    void    handle_mouse_release(QWidget* wid,QMouseEvent* e);
    void    handle_mouse_double_press(QWidget* wid);

    void    handle_all_mouse_press(QMouseEvent* e);
    void    handle_all_mouse_release(QMouseEvent* e);
    void    handle_all_mouse_move(QMouseEvent* e);
protected slots:
    void    edit();
    void    remove();
    void    up();
    void    down();
protected:
    void    edit(int index);
private:
    Ui::QPointFsEditorDialog *ui;
protected:
    int     m_ret;
    QVariant    m_value;
    QList<QWidget*>             m_point_handle_widgets;
    QPoint                      m_last_point;
    enPointType                 m_type;
private slots:
    void on_addBtn_clicked();
    void on_okBtn_clicked();
    void on_cancelBtn_clicked();
    void on_autoBtn_clicked();
};

#endif // QPOINTFSEDITORDIALOG_H
